
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @module read-item
* @author: Hjava
* @description: 已读时间定义类
* @since: 2018-07-23 11:34:57
*/
var constant_1 = __webpack_require__(/*! _util/constant */ "./src/core/utils/constant.ts");
var sessionIdProcessor_1 = __webpack_require__(/*! _Eutils/sessionIdProcessor */ "./src/extra/utils/sessionIdProcessor.ts");
var userData_1 = __webpack_require__(/*! _util/userData */ "./src/core/utils/userData.ts");
var Read = /** @class */ (function () {
    function Read(_a) {
        var uid = _a.uid, deviceType = _a.deviceType, msgUuid = _a.msgUuid, syncReadItems = _a.syncReadItems;
        this.uid = '';
        this.deviceType = 0;
        this.uuid = '';
        this.readItems = [];
        this.uid = uid;
        this.deviceType = deviceType;
        this.uuid = msgUuid;
        this.readItems = syncReadItems.map(function (readItem) {
            return ReadItem.createReadItem(readItem);
        });
    }
    Read.prototype.toString = function () {
        return 'Read{'
            + ' uid:' + this.uid
            + ' deviceType:' + this.deviceType
            + ' uuid:' + this.uuid
            + ' readItems:' + this.readItems
            + ' }';
    };
    return Read;
}());
exports.default = Read;
var ReadItem = /** @class */ (function () {
    function ReadItem(_a) {
        var uid = _a.uid, sessionType = _a.sessionType, _b = _a.channelId, channelId = _b === void 0 ? userData_1.default.get('channelId') : _b, sid = _a.sid, type = _a.type, peerAppId = _a.peerAppId, _c = _a.time, time = _c === void 0 ? 0 : _c, _d = _a.svrTime, svrTime = _d === void 0 ? 0 : _d, uuid = _a.uuid;
        this.sessionId = '';
        this.uid = '0';
        this.channelId = 0;
        this.type = '';
        this.peerAppId = 0;
        this.time = 0;
        this.svrTime = 0;
        this.sessionId = sessionIdProcessor_1.default.create({ uid: uid, channelId: channelId, sid: sid });
        this.sessionType = sessionType;
        this.uid = uid;
        this.channelId = channelId;
        this.type = type;
        this.peerAppId = peerAppId;
        this.time = time;
        this.svrTime = svrTime;
        this.sid = sid;
    }
    ReadItem.prototype.toString = function () {
        return 'ReadItem{'
            + ' sessionId:' + this.sessionId
            + ' type:' + this.type
            + ' svrTime:' + this.svrTime
            + ' time:' + this.time
            + ' }';
    };
    ReadItem.createReadItem = function (readItem) {
        switch (readItem.sessionType) {
            case constant_1.SESSION_TYPE.CHAT:
            case constant_1.SESSION_TYPE.CHAT2:
            case constant_1.SESSION_TYPE.GROUP_CHAT: {
                return new IMReadItem(readItem);
            }
            case constant_1.SESSION_TYPE.PUB_CHAT:
            case constant_1.SESSION_TYPE.PUB_CHAT2:
            case constant_1.SESSION_TYPE.CS_CHAT2:
            case constant_1.SESSION_TYPE.CS_CHAT: {
                return new PubReadItem(readItem);
            }
        }
    };
    return ReadItem;
}());
var IMReadItem = /** @class */ (function (_super) {
    __extends(IMReadItem, _super);
    function IMReadItem(data) {
        return _super.call(this, data) || this;
    }
    return IMReadItem;
}(ReadItem));
var PubReadItem = /** @class */ (function (_super) {
    __extends(PubReadItem, _super);
    function PubReadItem(data) {
        var _this = _super.call(this, data) || this;
        _this.pubId = '';
        _this.peerUid = '';
        _this.pubId = data.pubId;
        _this.peerUid = data.peerUid;
        return _this;
    }
    return PubReadItem;
}(ReadItem));


//# sourceURL=webpack://MTDX/./src/extra/models/read.ts?